﻿using DataModels.Dto;
using DataModels.Dto.Community;
using Microsoft.AspNetCore.Mvc;
using Services.Community;
using Utils;

namespace PropertyManagementWebApi.Controllers.Community
{
    public class ServiceEvaluationController(ServiceEvaluationService serviceEvaluationService) : BaseController
    {
        protected readonly ServiceEvaluationService _serviceEvaluationService = serviceEvaluationService;
        /// <summary>
        /// 通过问卷UUID获取服务评价
        /// </summary>
        /// <param name="UUID"></param>
        /// <param name="CreateUser"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetLastServiceEvaluationByUUID(Guid UUID)
        {
            return _serviceEvaluationService.GetLastServiceEvaluationByUUID(UUID);
        }

        /// <summary>
        /// 通过问卷activitiesNumber获取服务评价
        /// </summary>
        /// <param name="UUID"></param>
        /// <param name="CreateUser"></param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetServiceEvaluationByactivitiesNumber(int activitiesNumber)
        {
            return _serviceEvaluationService.GetServiceEvaluationByactivitiesNumber(activitiesNumber);
        }

        /// <summary>
        /// 获取最新问卷
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetLastServiceEvaluation([GeneralRequired] Guid ProjectUUID)
        {
            return _serviceEvaluationService.GetLastServiceEvaluation(ProjectUUID);
        }

        /// <summary>
        /// 提交问卷
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel SubmitServiceEvaluation(SubmitServiceEvaluationInfo info)
        {
            return _serviceEvaluationService.SubmitServiceEvaluation(info);
        }

        /// <summary>
        /// 获取服务评价列表 add by tianjh 20250731
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        [HttpPost]
        public ResponseModel GetServiceEvaluationList(ServiceEvaluationInfo info)
        {
            return _serviceEvaluationService.GetServiceEvaluationList(info);
        }

        /// <summary>
        /// 获取投票数量 
        /// </summary>
        /// <param name="ServiceEvaluationUUID"></param>
        /// <param name="No">题目号</param>
        /// <param name="Type">7候选人投票 8选项投票</param>
        /// <param name="Values">选项答案 多个用,分隔</param>
        /// <param name="CreateUser">创建人</param>
        /// <returns></returns>
        [HttpGet]
        public ResponseModel GetVotesNumber(string ServiceEvaluationUUID, int No,int Type,Guid CreateUser)
        {
            return _serviceEvaluationService.GetVotesNumber(ServiceEvaluationUUID, No, Type, CreateUser);
        }

        /// <summary>
        /// 生成二维码
        /// </summary>
        /// <param name="Url">扫描后跳转的URL</param>
        /// <param name="Size">图片大小</param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GenerateQRCode(string Url, int Size = 300)
        {
            var qrBytes = _serviceEvaluationService.GenerateQRCode(Url, Size);
            return File(qrBytes, "image/png");
        }


    }
}
